//
//  NetWorkState.m
//  豆瓣
//
//  Created by lanou on 15/10/20.
//  Copyright (c) 2015年 神逻辑. All rights reserved.
//

#import "NetWorkState.h"
#import "Reachability.h"
@implementation NetWorkState

+ (NetWorkState *)shareInstance
{
    static NetWorkState *state = nil;
    if(state == nil)
    {
        state = [[NetWorkState alloc]init];
    }
    return state;
}




//判断网络状态
//我们的这个方法 是基于第三方 Reachability 返回值为一个BOOL类型 NO代表没有网络 YES代表有网络
- (BOOL)reachability
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.baid.com"];
    switch ([r currentReachabilityStatus]) {
        case NotReachable:
            NSLog(@"没有网络");
            return NO;
            break;
        case ReachableViaWWAN:
            NSLog(@"移动网络");
            return YES;
            break;
        case ReachableViaWiFi:
            NSLog(@"WIFI网络");
            return YES;
            break;
        default:
            break;
    }
}
@end
